import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

import '../../i18n/translation.dart';
import '../../services/config.dart';

class TestLogic extends GetxController {
  /// 语言切换
  onLanguageSelected() {
    var en = Translation.supportedLocales[0];
    var zh = Translation.supportedLocales[1];
    ConfigService.to.setLanguage(
        ConfigService.to.locale.toLanguageTag() == en.toLanguageTag()
            ? zh
            : en);
    update();
  }

  /// 主题切换
  onThemeSelected(String themeKey) async {
    await ConfigService.to.setThemeMode(themeKey);
    update();
  }


  ///输入框表单验证
  // 表单key
  final GlobalKey<FormState> formKey = GlobalKey<FormState>();

  // 用户名
  TextEditingController usernameController = TextEditingController();

  // 密码
  TextEditingController passwordController = TextEditingController();

  @override
  void onClose() {
    super.onClose();
    usernameController.dispose();
    passwordController.dispose();
  }
}
